package leecode

func minMoves(target int, maxDoubles int) int {
	var result int
	for target > 1 {
		if maxDoubles == 0 {
			return result + target - 1
		}
		if target%2 > 0 {
			target--
			result++
		}
		maxDoubles--
		result++
		target = target / 2
	}
	return result

}
